//
//  GxTabBarController.swift
//  microblog
//
//  Created by 记忆不为 on 16/9/17.
//  Copyright © 2016年 记忆不为. All rights reserved.
//

import UIKit

@available(iOS 10.0, *)
class GxTabBarController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let newTabBar = GxMainTabBar()
        newTabBar.addButtonDidClick = {() ->Void in
            
            
        }
        
        self.setValue(newTabBar, forKey: "tabBar")
        
        addChildViewController(childVc: GxHomeViewController(), title: "首页", image: "tabbar_home")
        addChildViewController(childVc: GxMessageViewController(), title: "消息", image: "tabbar_message_center")
        addChildViewController(childVc: GxDiscoverViewController(), title: "发现", image: "tabbar_discover")
        addChildViewController(childVc: GxProfileViewController(), title: "我", image: "tabbar_profile")
        
    }
    
    private func addChildViewController(childVc: UIViewController,title: String,image: String) {
        
        childVc.title = title
        childVc.tabBarItem.image = UIImage(named: image)
        
        childVc.tabBarItem.selectedImage = UIImage(named: image + "_selected")?.withRenderingMode(.alwaysOriginal)
        
        childVc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orange], for: .selected)
        
        addChildViewController(UINavigationController(rootViewController: childVc))
    }
}


